﻿using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;

namespace AddFileHeaders
{

    internal interface Filter
    {
        bool IsMatch(ProjectItem p);
    }

    internal class FileTypeFilter : Filter
    {

        private string dotext = string.Empty;
        private string extension = string.Empty;
        public string Extension
        {
            get { return this.extension; }
            set
            {
                this.extension = value;
                this.dotext = "." + value.Replace(".", string.Empty).ToLower();
            }
        }

        public FileTypeFilter()
        {

        }

        public FileTypeFilter(string extension)
            : this()
        {
            this.Extension = extension;
        }

        public bool IsMatch(EnvDTE.ProjectItem p)
        {
            return p.Name.ToLower().EndsWith(this.dotext);
        }

        public override string ToString()
        {
            return string.Format("File types with extension '{0}'.", this.extension);
        }

    }

}
